-
Notifications
You must be signed in to change notification settings - Fork 393
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle git blame #761
Handle git blame #761
Conversation
bf91c6e
to
298f4f7
Compare
cc @th1000s @Kr1ss-XD FYI in case you'd like to give thoughts. I may merge this to master, but please don't let that dissuade you from commenting if you feel like it. This PR resurrects and extends the git blame work initially discussed in #426. There's quite a bit of discussion in that issue: basically, the implementation here is intended to work for users with vanilla git configs i.e. who are not making use of git settings such as blame.coloring, color.blame.highlightRecent, blame.date, blame.showEmail. But a different approach might be required if delta is to enhance blame for users making use of those git settings. I've made two changes to what I showed in #426
|
This is a great idea. The output looks much more clearly arranged like that. I'm looking forward to check this branch out for testing, most likely the upcoming weekend 😃 |
71f1ede
to
6c07c1f
Compare
@dandavison I downloaded this branch and built it (per #426, after nuking ~/.cargo to get the build to work) and get good results with Rust files (i.e. ... but it does not appear to work on C\C++ source code (e.g. |
I'm seeing this too, however I don't necessarily think it has to do with the files being C source code vs. Rust. I rather suspect this to be caused by large sized repositories, more precise large repo histories. For example, I have cloned this repository, which only contains a handful of On the other hand, if I do |
Thanks @zachriggle @Kr1ss-XD: yes, as @Kr1ss-XD says the problem was due to history size: in my initial implementation I had hardcoded an assumption that the commit hash would be truncated to 8 characters, and then forgotten to go back and do something actually reasonable. It appears that in repos with more history, git automatically displays more characters of the hash to avoid the possibility of displaying two distinct commits with identical formatting. So, we assume 7-40 characters now. - [0-9a-f]{8} # commit hash
+ [0-9a-f]{7,40} # commit hash |
One change I'm planning to make to this branch is the following: Currently, due to recycling of colors from the palette, it's possible that two distinct commits appearing next to each other would be assigned the same color. I'm thinking of choosing a different color in that situation. In other words I would give more importance to "give neighboring commits different colors" than to "ensure that a given commit always receives the same color". |
That sounds like a great idea!
How can one customize the palette of available colors?
|
That's the |
I like the idea, too. It would be even better if this could be toggled on or off by a config setting. |
That's correct. It can also be configured by
The smallest allowed length is 4 though, according to the documentation. Maybe it would be better to use that as a minimum for the regex ? |
ddafe23
to
cb88ab2
Compare
Thanks; done. (Btw for anyone building this branch you may have to put up with force-pushes to it, so |
What is the current state and reasoning for/against syntax highlighting? I see the first pair of screenshot still have it, but later ones and my local build do not. |
Thank you, I had entirely forgotten about this. In 0b8f145 I added a
Anyone have any better suggestions here? One thing that occurs to me is that it if someone wanted to create a rust tool to automatically predict language from source code, then that could make a nice rust crate. It really seems that it is not a problem pushing at the frontiers of machine learning :) Github has a tool that does this: https://github.com/github/linguist/blob/master/docs/how-linguist-works.md I believe that it wouldn't be hard to use the data used by their classifier (naive Bayes FWIW) and make a Rust version, i.e. skipping all the hard work of collecting the dataset. But, something of a tangent for a branch trying to add blame handling. |
f467620
to
80e1ca7
Compare
When the I think it would be nicer to suppress those characters, too. @dandavison ? EDIT/ I just realized that it would probably look worse if delta did that, because then also the |
@Kr1ss-XD hm, yes as you say, we can either have those lines blank for variable content only (as currently) or we can have them completely blank. I went for the former because at the very least, users are going to want a separating character at the right-hand end to be present in a blank line. Incidentally, (I propose |
One quick solution would be to check the command line of the parent process, then |
776b746
to
e423ecf
Compare
Fantastic. This PR is now using @th1000s's parent process inspection utility, so there should no longer be any need for |
I have actually tried that a while ago, and I kind of got hyperlinks working in tmux, in combination with your |
e423ecf
to
8f0d357
Compare
21b8b1e
to
7170f9f
Compare
@@ -15,6 +15,8 @@ name = "delta" | |||
path = "src/main.rs" | |||
|
|||
[dependencies] | |||
chrono = "0.4.19" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a security bug in this library (flagged by cargo audit). But I think there's nothing we can do about our exposure other than wait for upstream changes because syntect uses the library, and we can't replace syntect.
if let Some(field) = field { | ||
let field = pad(&field); | ||
if is_repeat { | ||
s.push_str(&" ".repeat(measure_text_width(&field))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: it should be possible to determine the required width once only and thereafter construct the blank line more efficiently.
7170f9f
to
95f62d2
Compare
Ref #426